package com.example.springbootlearn.aware;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.stereotype.Component;

/**
 * @author caiji Mr. Li
 * @date 2019/11/7 22:21
 */
@Component
public class Test implements BeanFactoryAware {

    private BeanFactory beanFactory;

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        this.beanFactory=beanFactory;
    }

    public void testAware(){
       Hello hello =(Hello) beanFactory.getBean("hello");
       hello.say();
    }
}
